class ArrayStack {
  constructor () {
    this.items = []
  }

  push (element) {
    this.items.push(element)
  }

  pop () {
    return this.items.pop()
  }

  peek () {
    if (this.items.length === 0) {
      throw new Error('stack is empty')
    }
    return this.items[this.items.length - 1]
  }

  isEmpty () {
    return this.items.length === 0
  }

  getSize () {
    return this.items.length
  }
}

export default ArrayStack
